package com.yic.module.qms.dal.mysql.inspectprocess;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.qms.dal.dataobject.inspectprocess.InspectProcessDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.qms.controller.admin.inspectprocess.vo.*;

/**
 * 过程检验 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface InspectProcessMapper extends BaseMapperX<InspectProcessDO> {

    default PageResult<InspectProcessDO> selectPage(InspectProcessPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectProcessDO>()
                .eqIfPresent(InspectProcessDO::getCode, reqVO.getCode())
                .eqIfPresent(InspectProcessDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(InspectProcessDO::getMoId, reqVO.getMoId())
                .eqIfPresent(InspectProcessDO::getItemProduceId, reqVO.getItemProduceId())
                .eqIfPresent(InspectProcessDO::getProcessId, reqVO.getProcessId())
                .eqIfPresent(InspectProcessDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(InspectProcessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectProcessDO::getId));
    }

    default List<InspectProcessDO> selectList(InspectProcessExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectProcessDO>()
                .eqIfPresent(InspectProcessDO::getCode, reqVO.getCode())
                .eqIfPresent(InspectProcessDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(InspectProcessDO::getMoId, reqVO.getMoId())
                .eqIfPresent(InspectProcessDO::getItemProduceId, reqVO.getItemProduceId())
                .eqIfPresent(InspectProcessDO::getProcessId, reqVO.getProcessId())
                .eqIfPresent(InspectProcessDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(InspectProcessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectProcessDO::getId));
    }

    default List<InspectProcessDO> selectListByMoAndProcess(Long moId, Long processId) {
        return selectList(new LambdaQueryWrapperX<InspectProcessDO>()
                .eq(InspectProcessDO::getMoId, moId)
                .eq(InspectProcessDO::getProcessId, processId));
    }
}
